/**
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *    
 *    Linking this library statically or dynamically with other modules 
 *    is making a combined work based on this library. Thus, the terms and
 *    conditions of the GNU General Public License cover the whole
 *    combination.
 *    
 *    As a special exception, the copyright holders of this library give 
 *    you permission to link this library with independent modules to 
 *    produce an executable, regardless of the license terms of these 
 *    independent modules, and to copy and distribute the resulting 
 *    executable under terms of your choice, provided that you also meet, 
 *    for each linked independent module, the terms and conditions of the 
 *    license of that module.  An independent module is a module which 
 *    is not derived from or based on this library.  If you modify this 
 *    library, you may extend this exception to your version of the 
 *    library, but you are not obligated to do so.  If you do not wish 
 *    to do so, delete this exception statement from your version.
 *
 *    Project: Financas Pessoais
 *    Author : Igor Salles
 */
package org.fp.logger;

/**
 * imports 
 */
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;

/**
 * Class to open and put logging exit on an external window. The window is 
 * serializable to avoid open various instances of the logger handler. original 
 * <code>code</code> from Samudra Gupta Aprees Copyright© 2003 ISBN:1590590996.
 * 
 * @author Samudra Gupta
 */
public class LogWindow extends JFrame {
    //local variables
    private int width;
    private int height;
    //window componets
    private JTextArea txtArea = null;
    private JScrollPane jspane = null;
    
    //constructor override
    public LogWindow(String title, int width, int height){
        super(title);
        //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setSize(width, height);
        txtArea = new JTextArea();
        jspane = new JScrollPane(txtArea);
        getContentPane().add(jspane);
        //tamanho da tela dimensao
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        System.out.println(""+screenSize.toString());
        //this.setLocationRelativeTo(null);
        this.setLocation(screenSize.width-width, screenSize.height-height);
        setVisible(true);
        
    } //constructor LogWindow
    
    /**
     * This method serializes the incoming log and append to the text area.
     * @param data the Logging information data.
     */
    public void showInfo(String data){
        txtArea.append(data);
        this.getContentPane().validate();
    }

} //class LogWindow
